#pragma warning(disable:4996)
#pragma warning(disable:6031)

#include <stdio.h>

void Swap(int* x, int* y)
{
	int t = *x;
	*x = *y;
	*y = t;
}

void QuickSort(int* arr, int left, int right)
{
	if (left >= right)
	{
		return;
	}
	int begin = left;
	int end = right;
	int key = arr[left];
	int cur = left + 1;
	while (cur <= right)
	{
		if (arr[cur] < key)
		{
			Swap(&arr[cur++], &arr[left++]);
		}
		else if (arr[cur] > key)
		{
			Swap(&arr[cur], &arr[right--]);
		}
		else
		{
			cur++;
		}
	}
	QuickSort(arr, begin, left - 1);
	QuickSort(arr, right + 1, end);
}

int main()
{
	int arr[] = { 2,4,9,1,0,3,5,6,4,0 };
	int sz = sizeof(arr) / sizeof(arr[0]);

	QuickSort(arr, 0, sz - 1);

	for (int i = 0; i < sz; i++)
	{
		printf("%d ", arr[i]);
	}
	return 0;
}